package com.sduept.nwld.fault.handler;

import com.sduept.bigdata.fault.analysis.handler.impl.AbstractCommonHandler;
import com.sduept.bigdata.fault.common.FaultHandlerContext;
import com.sduept.bigdata.fault.common.HandlerContext;
import com.sduept.bigdata.fault.entity.FaultAuxiliaryInfo;
import com.sduept.bigdata.fault.entity.FaultRecord;
import com.sduept.bigdata.fault.manager.FaultRecordQueryManager;
import com.sduept.bigdata.weather.manager.FaultWeatherInfoManager;
import com.sduept.utils.SpringContext;

public class FaultAuxiliaryInfoHandler extends AbstractCommonHandler {
	private FaultWeatherInfoManager wdmm = SpringContext.getBean(FaultWeatherInfoManager.class);
	private FaultRecordQueryManager frqm = SpringContext.getBean(FaultRecordQueryManager.class);
	@Override
	public void logic(HandlerContext context) {
		FaultHandlerContext faultContext = (FaultHandlerContext)context;
		FaultRecord fr = faultContext.getCurrentFaultRecord();
		FaultRecord record = frqm.findById(fr.getId());
		String thunderMsg = wdmm.getNewFaultThunderInfo(record);
		String iceMsg  = wdmm.getNewFaultIceInfo(record);
		FaultAuxiliaryInfo faultAuxiliaryInfo = new FaultAuxiliaryInfo();
		faultAuxiliaryInfo.setThunderInfo(thunderMsg);
		faultAuxiliaryInfo.setIceInfo(iceMsg);
		record.setFaultAuxiliaryInfo(faultAuxiliaryInfo);
		//frpm.saveFaultRecordOnly(record);//该方法存在拦截器，后期需要优化
		dao.createOrUpdate(record, FaultRecord.class);
	}

	@Override
	public boolean asynExecute() {
		return false;
	}
	
}
